package cn.itcast.javabase;

/**
 * @title: This02
 * @Author Zhou
 * @Date: 2022/1/18 13:31
 * @Version 1.0
 */
public class This02 {
    public static void main(String[] args) {
        Person01 person01 = new Person01("mike", 20, "male");
        Person01 person011 = new Person01("tom", 20, "female");
        boolean b = person011.compareTo(person01);
        System.out.println("b = " + b);
    }
}

class Person01 {
    String name;
    int age;
    String sex;

    public Person01(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }

    public boolean compareTo(Person01 p1) {
//        if (this.name.equals(p1.name) && this.age == p1.age){
//            return true;
//        }else {
//            return false;
//        }
        return this.name.equals(p1.name) && this.age == p1.age;
    }
}